home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / FMAT Editor 1.0.1 folder / About FMAT Editor… next >
Encoding:
Text File  |  1993-11-04  |  5.0 KB  |  58 lines  |  [ttro/ttxt]

  1. FMAT EDITOR
  2. by Michael Hecht
  3.  
  4. Version 1.0.1
  5. November 3, 1993
  6.  
  7.  
  8.  
  9. LEGALESE
  10. FMAT Editor is FREE. This software is Copyright © 1993 by Michael Hecht. All Rights Reserved. You may copy and distribute it freely, so long as you don’t make any money from it. Please be sure to distribute all the files in this package together, since I hate getting software without any instructions.
  11.  
  12.  
  13. WHAT IT DOES
  14. Version 2.0 of the Script Manager introduced a cool set of routines for formatting numeric values. Given a format specification, these routines can format a floating-point number into a string, or read a floating-point number from a string. But since this is a Macintosh, the format itself must be able to handle different languages and different ways of writing numbers. So Apple invented “canonical formats,” formats that are “compiled” into a script-independent representation. If you want to edit the canonical format, you can “decompile” it back into human-readable text (called a “number format specification string”) which makes sense to the current script system and user.
  15.  
  16. All this is great, but there’s a missing piece. There’s no easy way for a developer to create a canonical format for later use in an application. That’s why I wrote this FMAT editor. It’s a ResEdit editor that lets you edit 'FMAT' resources—canonical formats.
  17.  
  18. RESTRICTIONS
  19. FMAT Editor requires Script Manager 2.0 or later and ResEdit 2.1 or later.
  20.  
  21.  
  22. INSTALLATION
  23. Installation is manual. Open your “ResEdit Preferences” file with ResEdit. It should be in your System Folder. Next open the file “FMAT Editor” and select all resource types (command-A) except 'vers' (command-click 'vers'). Copy and paste them into “ResEdit Preferences.” Save your changes and you’re done!
  24.  
  25.  
  26. EDITING
  27. Open the file “Sample FMATs.” This file contains some formats for displaying bytes, kilobytes, and megabytes of memory or disk space; percentages; and currency in U.S. dollars.
  28.  
  29. Open an 'FMAT' resource and you are presented with a dialog in which you can edit the human-readable number format specification string. Use tab or shift-tab to select the positive, negative, or zero portions of the format. Below the edit box are example values 1234.56, -1234.56, and zero, as they appear when this format is used. If a formatting error occurs, you see a message there instead. If the error is severe enough to prevent the format from compiling, the message appears in bold red text, and you cannot close the dialog until you correct the problem.
  30.  
  31. Beside the editing dialog is a floating palette of “number parts.” These are the tokens used by the format compiler to distinguish format elements in the current script on your computer. There are left- and right-quotes for enclosing literal strings; plus and minus signs; digits with various representations for leading zeroes (blank leading, zero leading, and suppressed leading); a thousands separator; a decimal point; a percentage symbol; an escape character (used before the other tokens to place them in a literal string); a separator for dividing the format into positive, negative, and zero parts; positive and negative exponent signs; and various literals that don’t require quotes. Simply click the buttons to type the symbols into the format.
  32.  
  33. If you change the current script while editing a format (using the Keyboard menu or command-space), FMAT Editor switches to the new script’s system font and starts using its number parts.
  34.  
  35.  
  36. CODE
  37. There are two THINK C source files, “FormatVal.c” and “FormatVal.h,” which contain the definition of a function FormatVal that formats a double into a string given an 'FMAT' resource ID. Feel free to adapt this code to your needs.
  38.  
  39.  
  40. REFERENCE
  41. You definitely need to get your hands on the new “Inside Macintosh: Text” from Addison-Wesley (ISBN 0-201-63298-5). There’s a nice section starting on p. 5-35 called “Working With Numeric Strings” that explains how numeric formatting works and how to build a number format specification string. 
  42.  
  43.  
  44. FUNKY STUFF
  45. The Script Manager is apparently not bug-free. FormatRecToString (née, Format2Str) has problems with double-byte characters in a literal. This shows up when you edit a format that was intended for a 2-byte script system. For example, with the Japanese script system installed, create a new format, switch to the Japanese keyboard, click the open quote button, and type “nihonn.” Press the space bar to get Kanji and press return to enter the characters. Click the close quote button and you have a format. Looks great! Now close the editor and reopen it. Looks like garbage! The format is perfectly useable, so long as you only edit it once.
  46.  
  47.  
  48. WHAT’S NEW IN 1.0.1?
  49. • Resize the number parts palette when the keyboard script is changed, to accomodate different font sizes and a different number of unquoted literals.
  50. • Update the examples when the keyboard script is changed, even if the format contains an error.
  51. • Support Cut/Copy/Paste/Clear commands for edit text field.
  52.  
  53.  
  54. YOURS TRULY
  55. I hope you enjoy using FMAT Editor. If you have any comments, suggestions, or bug reports, e-mail them to me at Michael_Hecht@mac.sas.com.
  56.  
  57. --Michael
  58.